package com.augurit.gzcgwsp.ywcmn.web;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.Page;
import org.springside.modules.web.struts2.Struts2Utils;

import com.augurit.common.base.action.CrudActionSupport;
import com.augurit.common.base.action.ExtCrudActionSupport;
import com.augurit.common.system.web.auth.form.LoginUserForm;
import com.augurit.common.util.ExtUtils;
import com.augurit.common.util.lang.DateUtils;
import com.augurit.common.util.lang.StringUtils;
import com.augurit.gzcgwsp.ywcmn.service.IYwComYslService;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComYslForm;

@SuppressWarnings("serial")
@Results({
    @Result(name = CrudActionSupport.SUCCESS, location = "/gzcgwsp/ywcmn/ywysl/YwYsl.jsp"),
    @Result(name = "DBLCLICK_WIN", location = "/gzcgwsp/ywcmn/ywysl/YwYsl-info.jsp")
})
public class YwComYslAction extends ExtCrudActionSupport<YwComYslForm> {

    @Autowired
    private IYwComYslService ywComYslService;
    
    private YwComYslForm form;
    private Page<YwComYslForm> page = new Page<YwComYslForm>(15);

    public String listData() throws Exception {
        String isYsl = super.getParameter("isYsl");
        ExtUtils.initPageFromExtGridParam(getRequest(), page);
        if (StringUtils.isNotBlank(isYsl)) {
            form.setYsl(Long.parseLong(isYsl));
        }
        LoginUserForm loginUserForm = this.getLoginUser();
        ywComYslService.getYslDataList(page, form,loginUserForm);
        renderText(Struts2Utils.getJsonString(page, DateUtils.YEAR_MOUTH_DAY_));
        return null;
    }
    
    @Override
    public String delete() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String list() throws Exception {
        return CrudActionSupport.SUCCESS;
    }
    
    public String info() throws Exception {
        return "DBLCLICK_WIN";
    }
    
    @Override
    protected void prepareModel() throws Exception {
        if (form == null) form = new YwComYslForm();
    }

    @Override
    public String save() throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

    public YwComYslForm getModel() {
        // TODO Auto-generated method stub
        return form;
    }

}
